package com.he.controller;

import com.he.dto.CityRankingDTO;
import com.he.service.ExpressDeliveryDataService;
import com.he.util.R;
import com.he.vo.*;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 小赫
 * <p>2025/7/29 11:48
 */
@RestController
@RequestMapping("/logistics")
@CrossOrigin
public class LogisticsController {
    @Resource
    ExpressDeliveryDataService edds;

    @GetMapping("currentVolume")
    @ApiOperation("当前到件数量")
    public R<CurrentVolumeVO> currentVolume() {
        return R.ok(edds.currentVolume());
    }

    @ApiOperation("获取派件入库量占比")
    @GetMapping("entryVolumeRatio")
    public R<List<EntryVolumeRatioVO>> entryVolumeRatio() {
        return R.ok(edds.entryVolumeRatio());
    }

    //    **请求参数**：
//
//            - `type`（可选）：派件或寄件类型（1: 派件, 2: 寄件）
//            - `company`（可选）：快递公司名称
//- `packageType`（可选）：快件类型（0: 文件, 1: 物品）
    @GetMapping("guangdongData")
    @ApiOperation("获取广东省寄派件数据")
    public R<List<GuangdongDataVO>> guangdongData(@RequestParam(value = "type", required = false) Integer type, @RequestParam(value = "company", required = false) String company, @RequestParam(value = "packageType", required = false) Integer packageType) {
        return R.ok(edds.guangdongData(type, company, packageType));
    }

    //    获取派件相关的各种数据，如入库件、在库件、出库件等。
    @GetMapping("dispatchData")
    @ApiOperation("获取派件相关的各种数据")
    public R<DispatchDataVO> dispatchData(@RequestParam(value = "type", required = false) Integer type, @RequestParam(value = "company", required = false) String company, @RequestParam(value = "packageType", required = false) Integer packageType) {
        return R.ok(edds.dispatchData(type, company, packageType));
    }

    //    各省派件数量前十榜单
    @GetMapping("provinceRanking")
    @ApiOperation("各省派件数量前十榜单")
    public R<List<CityRankingDTO>> provinceRankingShipping(@RequestParam(value = "company", required = false) String company, @RequestParam(value = "packageType", required = false) Integer packageType) {
        return R.ok(edds.provinceRankingShipping(company, packageType));
    }
    @ApiOperation("各省寄件数量前十榜单")
    @GetMapping("provinceRankingDelivery")
    public R<List<CityRankingDTO>> provinceRankingDelivery(@RequestParam(value = "company", required = false) String company, @RequestParam(value = "packageType", required = false) Integer packageType) {
        return R.ok(edds.provinceRankingDelivery(company, packageType));
    }

    @ApiOperation("获取物流流向数据")
    @GetMapping("flows")
    public R<List<LogisticsFlowVO>> flows(@RequestParam("cityId") Integer cityId,
                                          @RequestParam(value = "type" , required = true) int type,
                                          @RequestParam(value = "startDate", required = false) String startDate,
                                          @RequestParam(value = "endDate", required = false) String endDate,
                                          @RequestParam(value = "companyId", required = false) Integer companyId,
                                          @RequestParam(value = "expressType", required = false) Integer expressType) {
        List<LogisticsFlowVO> result = edds.getFlows(cityId,type, startDate, endDate, companyId, expressType);
        return R.ok(result);
    }




}